package com.crois.barrier.plugin;

import com.crois.barrier.common.enums.PluginTypeEnum;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @author Hou Ze Yu
 * @description door 插件接口
 * @date 2020/7/12
 */
public interface BarrierPlugin {

    /***
     * 处理请求并派发致下一个插件
     * @param exchange 当前请求
     * @param chain door插件链
     * @return
     */
    Mono<Void> execute(ServerWebExchange exchange, BarrierPluginChain chain);

    /***
     *
     * @return
     */
    PluginTypeEnum pluginType();
    /**
     * 插件名称
     * @return
     */
    String name();

    /**
     * 插件执行顺序
     * @return
     */
    int order();
    /**
     * 插件是否 执行
     * @param exchange
     * @return
     */
    default Boolean skip(ServerWebExchange exchange){return  false;}
}
